package com.tanhua.server.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tanhua.common.mapper.AnnouncementMapper;
import com.tanhua.common.pojo.Announcement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author feihao
 * @version 1.0
 * @date 2021/7/7 22:25
 */

@Service
public class AnnouncementService {


    @Autowired
    private AnnouncementMapper announcementMapper;


    /**
     * 单表查询announcement表所有列表，按时间倒序
     * @param page
     * @param pageSize
     * @return
     */
    public IPage<Announcement> queryAnnouncementList(Integer page, Integer pageSize){

        QueryWrapper<Announcement> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByDesc("created");
        return announcementMapper.selectPage(new Page<Announcement>(page, pageSize), queryWrapper);

    }
}

